mod spider;

use aruspider::engine::{Engine, EngineBuilder};
use aruspider::pipeline::ConsolePipeline;
use aruspider::*;
use log::debug;
use log4rs;
use spider::HttpbinSpider;
use std::sync::Arc;
use std::time::Instant;
use tokio::sync::Mutex;

#[tokio::main]
async fn main() {
    let now = Instant::now();
    log4rs::init_file("config/log4rs.yml", Default::default()).unwrap();

    let spider = HttpbinSpider { start_urls: vec![] };
    /*
    let mut engine = Engine::new(
        4,
        Arc::new(spider),
        Arc::new(vec![Mutex::new(Box::new(ConsolePipeline))]),
        Arc::new(vec![]),
    );
    */
    let mut engine = Engine::builder()
        .max(4)
        .spider(Arc::new(spider))
        .add_pipeline(Box::new(ConsolePipeline))
        .build();

    engine.run().await;
    debug!("程序结束, 耗时: {} 毫秒", now.elapsed().as_millis());
}
